package com.beiding.workordersystem.orders.common.controller;

import com.beiding.workordersystem.common.standard.R;
import com.beiding.workordersystem.common.utils.MyBeanUtils;
import com.beiding.workordersystem.orders.common.entity.FlowUp;
import com.beiding.workordersystem.orders.common.service.FlowUpService;
import com.beiding.workordersystem.orders.generalorder.vo.FlowUpVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/flowUp")
public class FlowUpController {

    @Autowired
    private FlowUpService flowUpService;

    @GetMapping("/list")
    R list(@RequestParam String processId) {
        return R.ok(flowUpService.list(processId));
    }

    @PostMapping("/add/general")
    R add(@RequestBody @Validated FlowUpVo vo) {
        FlowUp copy = MyBeanUtils.copy(vo, FlowUp.class);
        flowUpService.save(copy);
        return R.ok(copy.getId());
    }

    @PostMapping("/add/loop")
    R addLoop(@RequestBody @Validated FlowUpVo vo) {
        FlowUp copy = MyBeanUtils.copy(vo, FlowUp.class);
        flowUpService.saveLoop(copy);
        return R.ok(copy.getId());
    }



}
